package kr.ne.jay.SimpleString;

import java.util.Iterator;
import java.util.Vector;

public class WallConstraint implements IConstraint {

	private int m_type;

	public WallConstraint(int type) {
		m_type = type;
	}
	
	@Override
	public void calcConstraint(Vector<VerletPoint> points) {
		Iterator<VerletPoint> it = points.iterator();
		switch (m_type){
		case 0:
			while (it.hasNext()){
				VerletPoint point = it.next();
				if (point.pos.x < 0.f)
					point.pos.x = 0.f;
			}
			break;
		case 1:
			while (it.hasNext()){
				VerletPoint point = it.next();
				if (point.pos.y < 0.f)
					point.pos.y = 0.f;
			}
			break;
		}
		it = null;
	}
}
